const babel = require('@babel/core');

const code = `<h1>
hello<span style={{ color: 'red' }}>world</span>
</h1>`;

/**
 * 默认是 classic
 */
const result = babel.transformSync(code, {
  plugins: [
    [
      '@babel/plugin-transform-react-jsx',
      {
        runtime: 'classic',
      },
    ],
  ],
});

/*
React.createElement("h1", null, "hello", React.createElement("span", {
  style: {
    color: 'red'
  }
}, "world"));
*/

console.log(result.code);
